﻿using System.Linq;
using System.Collections.Generic;

namespace N2.BlogEngine.Items
{
	using N2;
	using N2.Details;

	public class BlogContainer : ContentItem
	{
		#region Containers

		public PostContainer Posts {
			get {
				return
					this.GetOrFindOrCreateChild<PostContainer>(
						"Posts",
						null);
			}
		}

		public PageContainer Pages {
			get {
				return
				  this.GetOrFindOrCreateChild<PageContainer>("Pages", null);
			}
		}

		public CategoryContainer Categories {
			get {
				return
					this.GetOrFindOrCreateChild<CategoryContainer>("Categories", null);
			}
		}

		#endregion Containers

		#region Collections

		public IDictionary<string, string> Settings {
			get { return
				this.GetDetailCollection("Settings", true)
					.AsDictionary<string>();
			}
		}

		public IList<string> PingServices {
			get { return
				this.GetDetailCollection("PingServices", true)
					.AsList<string>();
			}
		}

		public IList<string> StopWords {
			get { return
				this.GetDetailCollection("StopWords", true)
					.AsList<string>();
			}
		}

		public IDictionary<string, object> Storage {
			get { return
				this.GetDetailCollection("Storage", true)
					.AsDictionary<object>();
			}
		}

		#endregion Collections

		public override string IconUrl { get { return "~/pics/wrenchicon16.png"; } }
	}
}
